<?php
require_once('config.inc.php');//$pdo; $uid; ROOT
//echo '<br><br><br>';
//$uid = 1;
$result_rows = 0;
if($uid > 0){
	$sql = "SELECT a.uid,b.cname,a.uname,a.cardid,a.addr,a.tel,a.card_p,a.card_p1 FROM stu_info a LEFT JOIN class_info b ON a.cid=b.cid WHERE a.uid=?";
	$stmt = $pdo->prepare($sql);
	$stmt->execute([$uid]);
	//$stmt_rows = $stmt->rowCount();//获取查询结果行数
	//遍历结果
	$result_all = $stmt->fetchAll(PDO::FETCH_ASSOC);
	$result_rows = count($result_all);
	//print_r($result_all);
	/*while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
	    print_r($row);
	}*/
}

?>
<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
	<link rel="stylesheet" type="text/css" href="css/bootstrapValidator.min.css"/>
	<script src="js/jquery-3.5.1.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/bootstrapValidator.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/jquery.md5.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/language/zh_CN.js" type="text/javascript" charset="utf-8"></script>
	<style type="text/css">
		body {
			font-family: "Helvetica Neue", Helvetica, Arial, "Microsoft Yahei UI", "Microsoft YaHei", SimHei, "\5B8B\4F53", simsun, sans-serif;
			color: #666;
		}
		.navbar-brand{
			padding-top: 0;
		}
		.jumbotron{
			margin-bottom: 5px;
		}
		.footer{
			padding: 20px;
			background-color: #eee;
			border-top: 5px double #fff;
			
		}
	</style>
	<title>Document</title>
</head>
<body>
	<!--首页导航条-->
	<div class="navbar navbar-default navbar-fixed-top" style="margin-bottom: 1px;">
		<div class="container">
			<div class="navbar-header">
				<!--一般品牌logo会是一张图片.我们可以在下面a标签中放一个img标签.记得把a标签加个padding:0;不然图片不居中.
					
				-->
				<a class="navbar-brand" href="#"><img src="img/kpit2.png"/></a>
				<!--这个按扭后会智能显示:class="navbar-toggle",让要记得把下面折叠菜单关联起来 -->
				<button class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse">
					<!-- 让按扭有三条横线,好看些 -->
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
			</div>
			<div class="collapse navbar-collapse" id="navbar-collapse">
				<!--下拉时有一点点空隙,把UL的margin-top设为0就可以了.-->
				<ul class="nav navbar-nav navbar-right" style="margin-top: 0;">
					<li class="active"><a href="index.html"><span class="glyphicon glyphicon-home"></span>&nbsp;首页</a></li>
					<?php
					if($uid <= 0){
						echo '<li><a id="gologin" href="login.html" data-toggle="modal" data-target="#login-modal"><span class="glyphicon glyphicon-log-in"></span>&nbsp;登陆</a></li>
						<li><a id="goreg" href="reg.html" data-toggle="modal" data-target="#reg-modal"><span class="glyphicon glyphicon-user"></span>&nbsp;注册</a></li>';
					}else{
						echo '<li><a id="go-logout" href="logout.php"><span class="glyphicon glyphicon-log-out"></span>&nbsp;退出</a></li>
						<li><a href="logout.php"><span class="glyphicon glyphicon-camera"></span>&nbsp;学历</a></li>';
						echo $_SESSION['user']['power'];
						if($_SESSION['user']['power'] > 0){
							echo '<li><a href="admin.php"><span class="glyphicon glyphicon-camera"></span>&nbsp;管理</a></li>';
						}
					}
					?>
					<li><a href="about.php"><span class="glyphicon glyphicon-question-sign"></span>&nbsp;关于</a></li>
				</ul>
			</div>
		</div>
	</div>
	<!--未登陆页面-->
	<div style="margin-top: 55px;"></div>
	<div class="jumbotron">
		<div class="container">
			<h1>欢迎来到鲲鹏学历管理系统</h1>
			<p>本站点采用PHP+bootstrap框架制作,拥用bootstrap框架简单易用,并且可同时适应手机,平板,与电脑屏幕的特点,结合PHP的快速,高效,易用性开发...</p>
			<h3 class="text-info">开发日志及功能介绍:</h3>
			<p>
				2020年8月4日早上开工,下午14点正式上线(有BUG请及时联系霍老师:手机/微信:18973973799)....主要是用于登记未拿到毕业证的同学的信息,方便进行联系与管理
				<br />
				<span style="color: red;">1.目前最主要任务是核对学生信息与联系.请注册后第一时间填写个人信息与上传身份证复印件!</span>
				<br />
				2.后续功能开发中.....
			</p>
			<p>
				<?php
					if($uid <= 0){
						echo '<button id="gologin_1" class="btn btn-primary btn-lg" href="login.php" role="button">去登陆</button>
							<button id="goreg_1" class="btn btn-primary btn-lg" href="reg.php" role="button">去注册</button>';
					}else{
						if($result_rows == 1){
							echo '<a href="index1.php"><span class="btn btn-primary btn-lg">去修改个人信息</span></a>';
						}else{
							echo '<a href="index1.php"><span class="btn btn-primary btn-lg">去填写个人信息</span></a>';
						}
					}
				?>
			</p>			
		</div>
	</div>
	
	<!--提示栏-->
	<!--<div class="alert alert-success" role="alert">
		<div class="container">请登陆或注册!</div>
	</div>-->
	
	<!--个人信息栏-->
	<div class="container">
	<div class="panel panel-default">
		<div class="panel-heading"><span style="font-size: 18px;">个人信息</span>
			<?php
			if($uid > 0 && $result_rows == 1){
				echo '<a class="pull-right" href="index1.php"><span class="glyphicon glyphicon-edit"></span>去修改</a>';
			}elseif($uid > 0){
				echo '<a class="pull-right" href="index1.php"><span class="glyphicon glyphicon-edit"></span>去登记</a>';
			}
			?>
		</div>
			<div class="list-group">
				<div class="input-group">
					<span class="input-group-addon">本人的姓名:</span>
					<a href="#" class="list-group-item"><?php if($result_rows == 1) echo $result_all[0]['uname']; else echo '请先登陆'; ?></a>
				</div>
				<div class="input-group">
					<span class="input-group-addon">身份证号码:</span>
					<a href="#" class="list-group-item"><?php if($result_rows == 1) echo substr_replace($result_all[0]['cardid'],'********',6,8); else echo '请先登陆'; ?></a>
				</div>
				<div class="input-group">
					<span class="input-group-addon">身份证地址:</span>
					<a href="#" class="list-group-item"><?php if($result_rows == 1) echo $result_all[0]['addr']; else echo '请先登陆'; ?></a>
				</div>
				<div class="input-group">
					<span class="input-group-addon">毕业时班级:</span>
					<a href="#" class="list-group-item"><?php if($result_rows == 1) echo $result_all[0]['cname']; else echo '请先登陆'; ?></a>
				</div>
				<div class="input-group">
					<span class="input-group-addon">现联系电话:</span>
					<a href="#" class="list-group-item"><?php if($result_rows == 1) echo $result_all[0]['tel']; else echo '请先登陆'; ?></a>
				</div>
			</div>
			<div class="panel-body">
				<div class="thumbnail col-sm-6">
					<!--<img src="img/huodeming_01.jpg"/>-->
					<img src="<?php if($result_rows == 1) echo $result_all[0]['card_p']; else echo 'img/huodeming_01.jpg'; ?>"/>
				</div>
				<div class="thumbnail col-sm-6">
					<img src="<?php if($result_rows == 1) echo $result_all[0]['card_p1']; else echo 'img/huodeming_02.jpg'; ?>"/>
				</div>
			</div>
	</div>
	<!--邮寄信息栏-->
	<div class="panel panel-default">
		<div class="panel-heading"><span style="font-size: 18px;">你现在的物流信息,开发中...</span>(更换了记得及时更新或联系学校)
			<?php
			if($uid > 0){
				echo '<a class="pull-right" href="#"><span class="glyphicon glyphicon-edit"></span>开发中...</a>';
			}
			?>
			
		</div>
			<div class="list-group">
				<div class="input-group">
					<span class="input-group-addon">收件人姓名(必须本人):</span>
					<label href="#" class="list-group-item">请先登陆</label>
				</div>
				<div class="input-group">
					<span class="input-group-addon">收件人地址(必须本人):</span>
					<label href="#" class="list-group-item">请先登陆</label>
				</div>
				<div class="input-group">
					<span class="input-group-addon">收件人电话(必须本人):</span>
					<label href="#" class="list-group-item">请先登陆</label>
				</div>
			</div>
	</div>	
	</div>
	
	<div class="footer">
		<div class="container">
			<p class="text-center">招生计划 | 合作事宜 | 投诉建议</p>
			<p class="text-center">湘ICP 备00000000号  &copy; 2015-2018 XX官方网站. Powered by Bootstrap.</p>
		</div>
	</div>
	
	<!--登陆模态框-->
	<div id="login-modal" class="modal fade" tabindex="-1">
		<!--窗口申明-->
		<div class="modal-dialog">
			<!--内容区申明-->
			<div class="modal-content">
				<!--会在这加载登陆页面-->
			</div>
		</div>
	</div>
	<!--注册模态框-->
	<div id="reg-modal" class="modal fade" tabindex="-1">
		<!--窗口申明-->
		<div class="modal-dialog">
			<!--内容区申明-->
			<div class="modal-content">
				<!--会在这加载登陆页面-->
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	//为了让验证码每次都刷新.写事件处理
	$(document).on('show.bs.modal','.modal',function(e){
	    $('#gdcode').trigger('click');
	});
	$('#gologin_1').click(function(){
		$('#gologin').trigger('click');
	});
	$('#goreg_1').click(function(){
		$('#goreg').trigger('click');
	});
	$('#go-logout').click(function(e){
		e.preventDefault();//阻止a标签默认事件 
		$.ajax({
            type: 'get',
            url: 'ajax_logout.php',
            //data: formData,//$('#form1').serialize(),
            dataType: 'json',
            //contentType: false, //上传文件必须
			//processData: false, //上传文件必须
            success: function (result) {
            	//console.log(result);
                if (result.success == "1") {
                	//alert("注成功,确认后返回首页!");
                    //console.log(result.data);
                   	location.href = 'index.php';
                } else {
                    console.log('注消失败:'+result.msg);
                }
            },
            error: function (e) {
                alert("提交出错");
                console.log(e);
            }
        })
	});
	
</script>
</html>